package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TChkBillDetail;
import com.ruoyi.system.service.ITChkBillDetailService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 自检detail 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-02-20
 */
@Controller
@RequestMapping("/system/tChkBillDetail")
public class TChkBillDetailController extends BaseController
{
    private String prefix = "system/tChkBillDetail";
	
	@Autowired
	private ITChkBillDetailService tChkBillDetailService;
	
	@RequiresPermissions("system:tChkBillDetail:view")
	@GetMapping()
	public String tChkBillDetail()
	{
	    return prefix + "/tChkBillDetail";
	}
	
	/**
	 * 查询自检detail列表
	 */
	@RequiresPermissions("system:tChkBillDetail:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TChkBillDetail tChkBillDetail)
	{
		startPage();
        List<TChkBillDetail> list = tChkBillDetailService.selectTChkBillDetailList(tChkBillDetail);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出自检detail列表
	 */
	@RequiresPermissions("system:tChkBillDetail:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TChkBillDetail tChkBillDetail)
    {
    	List<TChkBillDetail> list = tChkBillDetailService.selectTChkBillDetailList(tChkBillDetail);
        ExcelUtil<TChkBillDetail> util = new ExcelUtil<TChkBillDetail>(TChkBillDetail.class);
        return util.exportExcel(list, "tChkBillDetail");
    }
	
	/**
	 * 新增自检detail
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存自检detail
	 */
	@RequiresPermissions("system:tChkBillDetail:add")
	@Log(title = "自检detail", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TChkBillDetail tChkBillDetail)
	{		
		return toAjax(tChkBillDetailService.insertTChkBillDetail(tChkBillDetail));
	}

	/**
	 * 修改自检detail
	 */
	@GetMapping("/edit/{citemCode}")
	public String edit(@PathVariable("citemCode") String citemCode, ModelMap mmap)
	{
		TChkBillDetail tChkBillDetail = tChkBillDetailService.selectTChkBillDetailById(citemCode);
		mmap.put("tChkBillDetail", tChkBillDetail);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存自检detail
	 */
	@RequiresPermissions("system:tChkBillDetail:edit")
	@Log(title = "自检detail", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TChkBillDetail tChkBillDetail)
	{		
		return toAjax(tChkBillDetailService.updateTChkBillDetail(tChkBillDetail));
	}
	
	/**
	 * 删除自检detail
	 */
	@RequiresPermissions("system:tChkBillDetail:remove")
	@Log(title = "自检detail", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(tChkBillDetailService.deleteTChkBillDetailByIds(ids));
	}
	
}
